Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step sim when paused #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Step sim when paused #129

wants to merge 2 commits into from

Conversation

Robadob
Copy link
Member

@Robadob Robadob commented Mar 26, 2023

Pressing o (I'm not tied to this key, its just next to p on the keyboard), now steps the simulation if the simulation is paused and the sim has processed it's next step.

This works with a double mutex, whereby render_buffer_mutex_pre is locked by the visualiser, prior to locking render_buffer_mutex (the normal pause mutex). After the lock of render_buffer_mutex is achieved, the lock on render_buffer_mutex_pre is released.

This allows us to quickly release the normal pause mutex, and lock render_buffer_mutex_pre, prior to re-locking the normal pause mutex.

This (albeit a race) should guarantee the simulation if waiting to lock the pause mutex, only has time to update the buffers and complete one step.

This approach works because, typically the simulation has completed it's next step and is waiting to update render buffers, where the pause mutex blocks it.

The downside of this approach is that it has no impact if the simulation is running slower than the time between your attempts to step the simulation (as the renderer can lock and release render_buffer_mutex_pre without any competition from the sim. This could be detected, by checking whether render_buffer_mutex_pre is already locked, and a message shared with the user.

Closes #124

First commit is a basic one, that adds alt camera controls with the arrow keys, i keep trying to use them with orthographic view.

Robadob added 2 commits March 26, 2023 13:11
I keep attempting this when using ortho view.
This does nothing if the simulation isn't ready, e.g. if it hasn't completed a new step since the sim last paused.

Closes #124
@Robadob Robadob requested a review from ptheywood March 26, 2023 12:46
@Robadob Robadob self-assigned this Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visualising one simulation step at a time
1 participant